home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / coffee.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  2.8 KB  |  90 lines

  1. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  2. ; At ECS Dept, University of Southampton, England.
  3.  
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ; This program is distributed in the hope that it will be useful,
  9. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. ; GNU General Public License for more details.
  12. ; You should have received a copy of the GNU General Public License
  13. ; along with this program; if not, write to the Free Software
  14. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  
  16.  
  17. (define (script-fu-coffee-stain inImage
  18.                 inLayer
  19.                 inNumber
  20.                 inDark)
  21.  
  22.    (set! theImage inImage)
  23.    (set! theHeight (car (gimp-image-height theImage)))
  24.    (set! theWidth (car (gimp-image-width theImage)))
  25.    (set! theNumber inNumber)
  26.    (set! theSize (min theWidth theHeight))
  27.  
  28.    (gimp-context-push)
  29.  
  30.    (gimp-image-undo-group-start theImage)
  31.  
  32.    (while (> theNumber 0)
  33.       (set! theNumber (- theNumber 1))
  34.       (set! theStain (car (gimp-layer-new theImage theSize theSize
  35.                           RGBA-IMAGE "Stain" 100
  36.                           (if (= inDark TRUE)
  37.                           DARKEN-ONLY-MODE NORMAL-MODE))))
  38.  
  39.       (gimp-image-add-layer theImage theStain 0)
  40.       (gimp-selection-all theImage)
  41.       (gimp-edit-clear theStain)
  42.  
  43.       (let ((blobSize (/ (rand (- theSize 40)) (+ (rand 3) 1))))
  44.             (gimp-ellipse-select theImage
  45.                  (/ (- theSize blobSize) 2)
  46.                  (/ (- theSize blobSize) 2)
  47.                  blobSize blobSize CHANNEL-OP-REPLACE TRUE 0 FALSE))
  48.  
  49.       (script-fu-distress-selection theImage theStain
  50.                     (* (+ (rand 15) 1) (+ (rand 15) 1))
  51.                     (/ theSize 25) 4 2 TRUE TRUE)
  52.  
  53.       (gimp-context-set-gradient "Coffee")
  54.  
  55.       (gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
  56.                GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
  57.                FALSE 0 0 TRUE
  58.                0 0 0 0)
  59.  
  60.       (gimp-layer-set-offsets theStain
  61.                   (- (rand theWidth) (/ theSize 2))
  62.                   (- (rand theHeight) (/ theSize 2)) theSize))
  63.  
  64.    (gimp-selection-none theImage)
  65.  
  66.    (gimp-image-undo-group-end theImage)
  67.  
  68.    (gimp-displays-flush)
  69.  
  70.    (gimp-context-pop))
  71.  
  72. ; Register the function with the GIMP:
  73.  
  74. (script-fu-register "script-fu-coffee-stain"
  75.             _"_Coffee Stain..."
  76.             "Draws realistic looking coffee stains"
  77.             "Chris Gutteridge"
  78.             "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  79.             "25th April 1998"
  80.             "RGB*"
  81.             SF-IMAGE       "The image" 0
  82.             SF-DRAWABLE    "The layer" 0
  83.             SF-ADJUSTMENT _"Stains"    '(3 1 10 1 1 0 0)
  84.             SF-TOGGLE     _"Darken only\n(Better, but only for images with alot of white)" TRUE)
  85.  
  86. (script-fu-menu-register "script-fu-coffee-stain"
  87.              _"<Image>/Script-Fu/Decor")
  88.